package com.gg.hml.service.impl;

import com.gg.common.pojo.DFile;
import com.gg.common.pojo.DModuleDetails;
import com.gg.common.pojo.DesignModule;
import com.gg.hml.mapper.ProductMapper;
import com.gg.hml.search.ProductFileSearch;
import com.gg.hml.service.ProductService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class ProductServiceImpl implements ProductService {





    @Resource
    private ProductMapper productMapper;

    @Override
    public DFile judgmentProductName(String productName) {
        return productMapper.judgmentProductName(productName);
    }

    @Override
    public ProductFileSearch<DFile> queryReviewInformation(ProductFileSearch<DFile> productFileSearch) {

        PageHelper.startPage(productFileSearch.getPageNum(),productFileSearch.getPageSize());
        PageInfo<DFile> pageInfo = new PageInfo<>(this.productMapper.queryReviewInformation(productFileSearch));
        productFileSearch.setRows(pageInfo.getList());
        productFileSearch.setTotal(pageInfo.getTotal());
        return productFileSearch;
    }

    @Override
    public String queryFirstKindId(String firstKindName) {
        return productMapper.queryFirstKindId(firstKindName);
    }

    @Override
    public String querySecondKindName(String secondKindName) {
        return productMapper.querySecondKindName(secondKindName);
    }

    @Override
    public String queryThirdKindName(String thirdKindName) {
        return productMapper.queryThirdKindName(thirdKindName);
    }

    @Override
    public void addProduct(DFile dfile) {
        productMapper.addProduct(dfile);
    }

    @Override
    public void updateProduct(DFile dfile) {
        productMapper.updateProduct(dfile);
    }

    @Override
    public ProductFileSearch<DFile> queryProfileEnquiries(ProductFileSearch<DFile> productFileSearch) {
        PageHelper.startPage(productFileSearch.getPageNum(),productFileSearch.getPageSize());
        PageInfo<DFile> pageInfo = new PageInfo<>(this.productMapper.queryProfileEnquiries(productFileSearch));
        productFileSearch.setRows(pageInfo.getList());
        productFileSearch.setTotal(pageInfo.getTotal());
        return productFileSearch;
    }

    @Override
    public void DeleteProduct(DFile dFile) {

        productMapper.DeleteProduct(dFile);
    }

    @Override
    public ProductFileSearch<DFile> QueryDeletedProduct(ProductFileSearch<DFile> productFileSearch) {
        PageHelper.startPage(productFileSearch.getPageNum(),productFileSearch.getPageSize());
        PageInfo<DFile> pageInfo = new PageInfo<>(this.productMapper.QueryDeletedProduct(productFileSearch));
        productFileSearch.setRows(pageInfo.getList());
        productFileSearch.setTotal(pageInfo.getTotal());
        return productFileSearch;
    }

    @Override
    public void PermanentlyDeletedProduct(int id) {
        productMapper.PermanentlyDeletedProduct(id);
    }

    @Override
    public ProductFileSearch<DFile> QueryMaterialsToBeDevelopedProduct(ProductFileSearch<DFile> productFileSearch) {
        PageHelper.startPage(productFileSearch.getPageNum(),productFileSearch.getPageSize());
        PageInfo<DFile> pageInfo = new PageInfo<>(this.productMapper.QueryMaterialsToBeDevelopedProduct(productFileSearch));
        productFileSearch.setRows(pageInfo.getList());
        productFileSearch.setTotal(pageInfo.getTotal());
        return productFileSearch;
    }

    @Override
    public void saveDesignModule(DesignModule designModule) {

        productMapper.saveDesignModule(designModule);
    }

    @Override
    public void saveDesignModuleDetails(List<DModuleDetails> dModuleDetails) {
        productMapper.saveDesignModuleDetails(dModuleDetails);
    }

    @Override
    public void updateDsignModuleTag(String productId) {
        productMapper.updateDsignModuleTag(productId);
    }

    @Override
    public int queryPrimaryKeyByDesignModule(String productId) {
        return productMapper.queryPrimaryKeyByDesignModule(productId);
    }

    @Override
    public ProductFileSearch<DesignModule> QueryNotApprovedProducts(ProductFileSearch<DesignModule> designModuleProductFileSearch) {
        PageHelper.startPage(designModuleProductFileSearch.getPageNum(),designModuleProductFileSearch.getPageSize());
        PageInfo<DesignModule> pageInfo = new PageInfo<>(this.productMapper.QueryNotApprovedProducts(designModuleProductFileSearch));
        designModuleProductFileSearch.setRows(pageInfo.getList());
        designModuleProductFileSearch.setTotal(pageInfo.getTotal());
        return designModuleProductFileSearch;
    }

    @Override
    public List<DModuleDetails> QueryDModuleDetails(String parent_id) {
        return productMapper.QueryDModuleDetails(parent_id);
    }

    @Override
    public void PassDesignModuleById(DesignModule designModule) {
        productMapper.PassDesignModuleById(designModule);
    }

    @Override
    public int QueryPassModuleCount() {
        return productMapper.QueryPassModuleCount();
    }

    @Override
    public int QueryWaitPassModuleCount() {
        return productMapper.QueryWaitPassModuleCount();
    }

    @Override
    public int QueryNoPassModuleCount() {
        return productMapper.QueryNoPassModuleCount();
    }

    @Override
    public void deleteModuleByDetailsNumber(int parentId, int detailsNumber) {

        productMapper.deleteModuleByDetailsNumber(parentId,detailsNumber);
    }

    @Override
    public void BatchInsertDMouleDetails(DModuleDetails dModuleDetails) {

        productMapper.BatchInsertDMouleDetails(dModuleDetails);
    }

    @Override
    public void BatchUpdateDMouleDetails(DModuleDetails dModuleDetails) {
        productMapper.BatchUpdateDMouleDetails(dModuleDetails);
    }

    @Override
    public void BatchUpdateDModuleStatus(DesignModule designModule) {
        productMapper.BatchUpdateDModuleStatus(designModule);
    }


}
